package exser;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

/**
 * @author: knowno
 * @create: 2025-09-17 10:45
 * @Version 1.0
 **/
public class TestSerializable {
    public static void main(String[] args) {

        User user = new User();
        user.setId("1");
        user.setUsername("knowno");
        user.setPassword("123");

        try {
            //序列化
            ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("user.txt"));
            oos.writeObject(user);
            oos.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
